package cn.edu.scut.sys.vo;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * Authority entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "authority", catalog = "scoredb")
@JsonIgnoreProperties(value={"hibernateLazyInitializer"})
public class Authority implements java.io.Serializable {

	private static final long serialVersionUID = 5856859399081809968L;

	// Fields

	private Long id;
	private Unit unit;
	private User user;
	private Boolean readable;
	private Boolean writable;
	private Integer level;

	// Constructors

	/** default constructor */
	public Authority() {
	}

	/** full constructor */
	public Authority(Unit unit, User user, Boolean readable, Boolean writable,
			Integer level) {
		this.unit = unit;
		this.user = user;
		this.readable = readable;
		this.writable = writable;
		this.level = level;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "unitId")
	public Unit getUnit() {
		return this.unit;
	}

	public void setUnit(Unit unit) {
		this.unit = unit;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "userId")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "readable")
	public Boolean getReadable() {
		return this.readable;
	}

	public void setReadable(Boolean readable) {
		this.readable = readable;
	}

	@Column(name = "writable")
	public Boolean getWritable() {
		return this.writable;
	}

	public void setWritable(Boolean writable) {
		this.writable = writable;
	}

	@Column(name = "level")
	public Integer getLevel() {
		return this.level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

}